Component({
  options: {
    addGlobalClass: true,
    state: false,
  },
  /**
   * 组件的属性列表
   */
  properties: {
    fix: {
      type: Boolean,
      value: false,
      observer: function(n, o) {
        n && this.setData({
          animationName: this.data.x ? 'right-start' : 'left-start'
        })
      }
    }
  },
  data: {
    show: false,
    dial: false,
    dial_pic:null,
    animationName: 'none',
    kf_img: null,
    show_customer_service:false
  },
  attached() {
    console.log('attached')
    var y = wx.getStorageSync('y')
    y ? this.setData({
      x: wx.getStorageSync('x'),
      y: wx.getStorageSync('y')
    }, function() {
      this.setData({
        show: true
      })
    }) : this.setData({
      x: getApp().windowWidth-60,
      y: getApp().windowHeight-260
    }, function() {
      this.setData({
        show: true
      })
    })
    this.setData({
      kf_img:wx.getStorageSync('STORE_CONFIG').store.service,
      dial:wx.getStorageSync('STORE_CONFIG').store.dial,
      dial_pic:wx.getStorageSync('STORE_CONFIG').store.dial_pic,
      show_customer_service:wx.getStorageSync('STORE_CONFIG').store.show_customer_service
    })
  },
  methods: {
    a1() {
      console.log('dianji')
    },
    a2(e) {
      var x = getApp().windowWidth,
        y = e.changedTouches[0].clientY
      this.setData({
        x: x / 2 > e.changedTouches[0].clientX ? 0 : x,
        y: y < 50 ? 50 : y - 25
      }, function() {
        this.triggerEvent('myevent')
        wx.setStorage({
          key: 'x',
          data: this.data.x
        })
        wx.setStorage({
          key: 'y',
          data: this.data.y
        })
      })
    },
    resetting() {
      /none|end/.test(this.data.animationName) || this.setData({
        animationName: this.data.x ? 'right-end' : 'left-end'
      })
    },
    calling: function() {
      getApp().core.makePhoneCall({
          phoneNumber: wx.getStorageSync('STORE_CONFIG').store.contact_tel
      });
    }
  },
})